import java.util.Scanner;
import java.util.Stack;

public class Leer_O_58 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println(reverseWords(sc.nextLine()));
    }
    static public String reverseWords(String s) {
        if(s.length()==0)
            return "";
        Stack<String> stack = new Stack<>();
        int l = 0;
        int num = 0;
        boolean flag = true;
        if(s.charAt(0)==' ')
            flag = false;
        for(int i = 0;i<s.length();i++) {
            if(i == s.length()-1&&flag==true) {
                if(s.charAt(i)==' ')
                    stack.push(s.substring(l,i));
                else
                    stack.push(s.substring(l,i+1));
                break;
            }
            if(i == s.length()-1&&flag==false&&s.charAt(i)!=' ') {
                stack.push(s.substring(i,i+1));
                num++;
            }
            if(i == s.length()-1&&flag==false)
                num--;
            if(s.charAt(i)==' '&&!flag) {
                continue;
            }
            if(s.charAt(i)!=' '&&!flag) {
                flag = true;
                l = i;
            }
            if(s.charAt(i)==' '&&flag) {
                stack.push(s.substring(l,i));
                num++;
                flag =false;
            }

        }
        StringBuilder sb = new StringBuilder();
        for(int i = 0;i<num+1;i++) {
            sb.append(stack.pop()).append(" ");
        }
        String re = sb.toString();
        if(re.length()==0)
            return re;

        while(true) {
            if(re.charAt(re.length()-1)!=' ')
                break;
            re = re.substring(0,re.length()-1);
        }
        return re;
    }
}
